package com.example.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.system.entity.Care;
import com.example.system.entity.Wheelchair;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface WheelchairMapper extends BaseMapper<Wheelchair> {

    @Select("SELECT * FROM wheelchair WHERE user_id = #{userId}")
    List<Wheelchair> findWheelchairByUserId(Integer userId);

    @Delete("DELETE FROM wheelchair WHERE wheelchair_id = #{wheelchairId}")
    int deleteWheelchairByWheelchairId(Integer wheelchairId);

    int addWheelchairByWheelchair(Wheelchair wheelchair);

    @Select("SELECT * FROM wheelchair WHERE wheelchair_id = #{wheelchairId};")
    Wheelchair findWheelchairByWheelchairID(Integer wheelchairId);

    @Update("UPDATE wheelchair SET wheelchair_type = #{wheelchairType},rental_end_time = #{rentalEndTime},wheelchair_price = #{wheelchairPrice} WHERE wheelchair_id = #{wheelchairId};")
    int updateWheelchairByWheelchair(Wheelchair wheelchair);

    @Update("UPDATE wheelchair SET finish = 1 WHERE wheelchair_id = #{wheelchairId};")
    void updateWheelchairFinishByWheelchairId(Integer wheelchairId);
}
